package okl.test.motionChart.renderers
{
	import flash.display.DisplayObject;
	import flash.display.Graphics;
	import flash.geom.Rectangle;
	import flash.text.TextFieldAutoSize;
	
	import mx.charts.HitData;
	import mx.charts.chartClasses.DataTip;
	import mx.charts.chartClasses.GraphicsUtilities;
	import mx.core.IUITextField;
	import mx.core.UIComponent;
	import mx.core.UITextField;
	import mx.graphics.IFill;
	import mx.graphics.SolidColor;
	import mx.graphics.SolidColorStroke;
	
	import okl.test.motionChart.BubbleChartDescriptor;
	import okl.test.motionChart.interfaces.IMotionBubbleData;
	
	public class MotionBubbleDataTip extends DataTip
	{
		public function MotionBubbleDataTip()
		{
			super();
		}
		
		/**
		 *  @private.
		 */
		private var _label:IUITextField;
		public var chartDescriptor:BubbleChartDescriptor;
		override public function set data(value:Object):void{
			super.data=value;
		}
		
		override public function get data():Object{
			return super.data;
		}
		
		
		private var _shadowFill:IFill = IFill(new SolidColor(0xAAAAAA, 0.55));
		private var stroke:SolidColorStroke = new SolidColorStroke(0, 0, 1);
		

		
		override protected function updateDisplayList(unscaledWidth:Number,
													  unscaledHeight:Number):void
		{
			super.updateDisplayList(unscaledWidth, unscaledHeight);
			
			var bdata:IMotionBubbleData = (data as HitData).item as IMotionBubbleData;
			var targetColor:uint = chartDescriptor.getBubbleColor(bdata);
			stroke.color= targetColor;
			setStyle("color", targetColor);
		
	
			
			var g:Graphics = graphics;
			g.clear();
			
			var xpos:Number = 0;
			var ypos:Number = 0;
			
			g.moveTo(measuredWidth, 2);
			
			
			_shadowFill.begin(g,
				new Rectangle(xpos, ypos, measuredWidth, measuredHeight),null);
			g.lineTo(measuredWidth + 2, 2);
			g.lineTo(measuredWidth + 2, measuredHeight + 2);
			g.lineTo(2,measuredHeight + 2);
			g.lineTo(2,measuredHeight);
			g.lineTo(measuredWidth - 2, measuredHeight - 2);
			g.lineTo(measuredWidth - 2, 2);
			_shadowFill.end(g);
			
			var fill:IFill = IFill(new SolidColor(getStyle("backgroundColor"), 0.8));
			
			GraphicsUtilities.fillRect(g, xpos, ypos, measuredWidth,
				measuredHeight, fill, stroke);			

		}
	}
}